//
//  BMPhotoIOTool.h
//  bigmama
//
//  Created by huyuchen on 2017/9/28.
//  Copyright © 2017年 盛成文化. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Photos/Photos.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import "BMPhotoIO_iOS7Tool.h"
#import "BMPhotoIO_iOS8Tool.h"
#import "BMPhotoIOAuthTool.h"
#import "BMPhotoIOAlbumModel.h"
#import "BMPhotoIOPhotoModel.h"
#import "BMPhotoIOVideoModel.h"

@interface BMPhotoIOTool : NSObject
SingletonH_lib(Tool)

// 相册
@property (nonatomic, strong) NSMutableArray *albumArray;

// 只有视频的相册
@property (nonatomic, strong) NSMutableArray *videoAlbumArr;

// 相册是否加载成功
@property (nonatomic, assign) BOOL albumLoaded;

//授权完成，查询本地视频完成回调
@property (nonatomic,copy) void(^checkAuthorFinishBlock)(NSArray *);

#pragma mark - iOS8及以后
/**
 根据相册获取照片
 
 @param collection PHAssetCollection相册对象
 */
- (void)photosWithCollection:(PHAssetCollection *)collection finishBlcok:(void (^)(id obj1, id obj2))finishBlock;

/**
 根据相册获取视频
 
 @param collection PHAssetCollection相册对象
 */
- (void)videosWithPhAssetCollection:(PHAssetCollection *)collection finishBlcok:(void (^)(id obj1, id obj2))finishBlock;

/**
 获取缩略图，适合九宫格显示
 
 @param asset  PHAsset图片对象
 */
- (void)thumbImageWithAsset:(PHAsset *)asset finishBlock:(void(^)(id obj))finishBLock;


/**
 获取原图数据data，限制最大容量可通过属性maxDB设置，没设置默认为5MB
 
 @param asset PHAsset图片对象
 */
- (void)originalImageDataWithAsset:(PHAsset *)asset finishBlock:(void(^)(id obj))finishBLock;

/**
 获取原图
 
 @param asset PHAsset图片对象
 */
- (void)originalImageWithAsset:(PHAsset *)asset finishBlock:(void(^)(id obj))finishBLock;

/**
 根据asset获取要缓存的图片，比缩略图大，比原图小，不模糊,适合没上传完显示
 
 @param asset PHAsset图片对象
 */
- (void)cacheImageWithAsset:(PHAsset *)asset finishBlock:(void(^)(id obj))finishBLock;

/**
 根据图片id获取PHAsset对象
 
 @param ID 图片唯一id
 @return PHAsset对象
 */
- (PHAsset *)getAssetWithID:(NSString *)ID;

#pragma mark - iOS7

/**
 根据相册获取图片数组
 
 @param group 相册
 @param finishBlock 遍历完成调用block，多次调用，以日期划分
 */
- (void)photosWithAssetGroup:(ALAssetsGroup *)group finishBlcok:(void(^)(id obj1, id obj2))finishBlock;

/**
 根据相册获取视频数组
 
 @param group 相册
 @param finishBlock 遍历完成调用block，多次调用，以日期划分
 */
- (void)videosWithAssetGroup:(ALAssetsGroup *)group finishBlock:(void(^)(id obj1, id obj2))finishBlock;

/**
 获取照片原图
 
 @param asset 照片模型
 @return 原图
 */
- (UIImage *)originalImageWithAssetInIOS7:(ALAsset *)asset;

/**
 保存图片到相机胶卷
 
 @param image 图片
 @param metadata 元数据
 @param finishedBlock 保存成功回调block
 */
- (void)saveImage:(UIImage *)image metadata:(NSDictionary *)metadata finishedBlock:(void(^)(id obj))finishedBlock;

@end
